//
//  feedBackViewController.m
//  SDSY
//
//  Created by dale on 2017/3/23.
//  Copyright © 2017年 蓝布鲁. All rights reserved.
//

#import "feedBackViewController.h"

@interface feedBackViewController ()<UITextViewDelegate>

@end

@implementation feedBackViewController{
    
    UITextView*    _contentTV;
    UIButton*      _button;
    UILabel*       _placeHolder;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"反馈";
    
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor=[UIColor colorWithRed:220/256.0 green:220/256.0 blue:221/256.0 alpha:1];
    
    //设置内容
    self.automaticallyAdjustsScrollViewInsets = false;
    _contentTV=[[UITextView alloc ] initWithFrame:CGRectMake(10, 80,self.view.width-20, 200)];
    
    _contentTV.keyboardType=UIKeyboardTypeDefault;
    _contentTV.delegate=self;
    [self setupPlaceHolder];
    
    
    //设置按钮
    _button=[UIButton buttonWithType:UIButtonTypeCustom];
    _button.frame=CGRectMake(self.view.width/2-50, _contentTV.bottomY+20, 100, 40);
    [_button setTitle:@"提交" forState:UIControlStateNormal];
    [_button addTarget:self action:@selector(submit) forControlEvents:UIControlEventTouchUpInside];
    
    _button.backgroundColor=[UIColor blueColor];
    [_button.titleLabel setTextColor:[UIColor whiteColor]];
    

    [self.view addSubview:_contentTV];
    [self.view addSubview:_button];
    
}

//设置线索
- (void)setupPlaceHolder
{
    _placeHolder = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, self.view.width - 2 * 15, 200)];
    _placeHolder.text = @"请输入您要反馈的内容.....";
    [_placeHolder sizeToFit];
    
    _placeHolder.textColor = [UIColor lightGrayColor];
    _placeHolder.numberOfLines = 0;
    _placeHolder.contentMode = UIViewContentModeTop;
    [_contentTV addSubview:_placeHolder];
}


//提交
-(void)submit{
    NSLog(@"submit");
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - UITextViewDelegate
- (void)textViewDidChange:(UITextView *)textView
{
    if (!textView.text.length) {
        _placeHolder.alpha = 1;
    } else {
        _placeHolder.alpha = 0;
    }
}

//关闭键盘
-(void) dismissKeyBoard{
    [_contentTV resignFirstResponder];
}








@end
